import React from "react";
import { Switch, Route, Redirect } from "react-router-dom";
import PrivateRoute from "./utils/PrivateRoute";
// import Login from "./pages/Login/Login"
// import Register from "./pages/Register/Register"
// import Index from "./pages/Index/Index"
// import List from "./pages/List/List"
// import Detail from "./pages/Detail/Detail"
// import Search from "./pages/Search/Search"
import "./App.less";

//懒加载
let Login = React.lazy(() => import("./pages/Login/Login"));
let Register = React.lazy(() => import("./pages/Register/Register"));
let Index = React.lazy(() => import("./pages/Index/Index"));
let List = React.lazy(() => import("./pages/List/List"));
let Detail = React.lazy(() => import("./pages/Detail/Detail"));
let Search = React.lazy(() => import("./pages/Search/Search"));
let Coupon = React.lazy(() => import("./pages/Coupon/Coupon"));

export default function App() {
  return (
    <div className="con">
      {/* 路由出口 */}
      <React.Suspense fallback={<div>正在努力加载中</div>}>
        <Switch>
          <Route path="/login" component={Login}></Route>
          <Route path="/register" component={Register}></Route>
          <PrivateRoute path="/index" component={Index}></PrivateRoute>
          <PrivateRoute path="/list" component={List}></PrivateRoute>
          <PrivateRoute path="/detail" component={Detail}></PrivateRoute>
          <PrivateRoute path="/search" component={Search}></PrivateRoute>
          <PrivateRoute path="/coupon" component={Coupon}></PrivateRoute>
          {/* <Route path="/index" component={Index}></Route>
          <Route path="/list" component={List}></Route>
          <Route path="/detail" component={Detail}></Route>
          <Route path="/search" component={Search}></Route> */}
          <Redirect to="/login"></Redirect>
        </Switch>
      </React.Suspense>
    </div>
  );
}
